<?php	
	$query_Recordset1riclibri = "select idMLU,titolo, depositati.prezzo,datares from depositati join libri using (idlibro) join carrelli using (idmlu) where Idcliente=$idc";
	$Recordset1riclibri = mysql_query($query_Recordset1riclibri, $mlu) or die(mysql_error());
	$row_Recordset1 = mysql_fetch_assoc($Recordset1riclibri);
	$total=mysql_num_rows($Recordset1riclibri);
?>
<script language="javascript" type="text/javascript">
	$('#checkallven').click(function () {
		$('.venclass:checkbox').attr('checked', this.checked);
	});
	
	$('#salvaven').click(function() {
		var res=[];
		$('#venid:checked').each(function() { 
		$('#venid:checked').fadeOut();
       res.push($(this).val());
     });
	   var jrole = $('#salvaven a').attr("href")+"&idmlu="+res;
       $('#tabrest').fadeOut(1000,function(){$('#tabrest').load(jrole,'',$('#tabrest').fadeIn(1000))}); 
		return false;
    }); 

    </script>
<h1 align="center">Libri venduti</h1>
<table border="1" align="center" class="tabellalibri">
  <tr>
    <td>&nbsp;</td>
    <td>ID</td>
    <td>titolo</td>
    <td>prezzo</td>
  </tr>
  <?php do {
	  $datares=$row_Recordset1['datares']; ?>
    <tr>
     <td><?php if ($datares=='0000-00-00')
	 {
		  echo "<input type=\"checkbox\" class=\"venclass\" id='venid' value=\"".$row_Recordset1['idMLU']."\"/>"; 
	 }
	 else
	 { 
	 	echo "&nbsp;";
	 } ?>
     </td>
      <td><?php echo $row_Recordset1['idMLU']; ?>&nbsp; </td>
      <td><?php echo $row_Recordset1['titolo']; ?>&nbsp; </td>
      <td><?php echo $row_Recordset1['prezzo']; ?>&nbsp; </td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1riclibri)); ?>
</table>
<input type="checkbox" id="checkallven"> Seleziona tutto <br />
<p>Totale libri venduti: <?php echo $total; ?> </p>
<button id="salvaven"><a href="restituzione/tabellalibrimagazzino.php?idc=<?php echo $idc; ?>">salva</a></button>
